package com.grantheath.erebus.controller.initializationCommands
{
	import com.grantheath.erebus.controller.URLCommands.ErebusHandleInvalidURLCommand;
	import com.grantheath.erebus.model.enum.notifications.ErebusURLNotifications;
	import com.grantheath.erebus.model.enum.names.ErebusProxyNames;
	import com.grantheath.erebus.model.interfaces.IErebusClassReferenceProxy;

	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.patterns.command.SimpleCommand;

	/**
	 * @author grantheath
	 */
	public class ErebusInitializeURLHandeling extends SimpleCommand implements ICommand 
	{
		override public function execute(notification : INotification) : void
		{
			var classReferenceProxy : IErebusClassReferenceProxy = facade.retrieveProxy(ErebusProxyNames.CLASS_REFERENCE_PROXY) as IErebusClassReferenceProxy;
			var URLProxyClass : Class = classReferenceProxy.URLProxyClass;
			var URLMediatorClass : Class = classReferenceProxy.URLMediatorClass;
			var PagePreloaderMediatorClass : Class = classReferenceProxy.pagePreloaderMediatorClass;
			var PageMediatorClass : Class = classReferenceProxy.pageMediatorClass;
			
			//register url commands
			facade.registerCommand(ErebusURLNotifications.HANDLE_INVALID_URL, ErebusHandleInvalidURLCommand);
			
			//register url proxie
			facade.registerProxy(new URLProxyClass());
			
			//register url mediators
			facade.registerMediator(new URLMediatorClass());
			facade.registerMediator(new PagePreloaderMediatorClass());
			facade.registerMediator(new PageMediatorClass());
		}
	}
}
